; This module services the real time interrupt
;
; Get a Real Time interrupt every One millisecond (using SOF interrupt)
;
; Strobe the Reader Board columns every 25msec so that no flicker is evident
; The circuitry is shown in Figure 6-22 except that Port C is used not Port B
; Pin assignment of Port C is:
; Bit 0 = Clock
; Bit 1 = Data
; Bit 2 = Reset
; Bit 3 = DIR/OE (0 = Write LEDs, 1 = Read Buttons)
ServiceTimerRoutine:
DJNZ Msec_counter, Done ; Only need to react every 25msec
MOV Msec_counter, #25 ; Reinitialize
SetupPointers:
MOV R0, #Low(PortC_OUT) ; Will strobe the hardware here
MOV R1, #Low(PortA_OUT) ; Will output data to here
MOV R2, #0001 ; PortC, Code for Clock Hi
MOV A, DisplayPosition ; Which column are we currently displaying
CJNE A, #39, NextColumn
ReadButtons: ; Before each full scan
MOV DPTR, #PortA_OE ; Need to flip Port A
CLR A
MOVX @DPTR, A ; Setup Port A for INPUT
MOV A, #01100b ; Set DIR and Reset = 1
MOVX @R0, A ; Enable hardware to input
MOV R1, #Low(PortA_Pins)
MOVX A, @R1 ; Get Port A data and save for a later Report
MOV ButtonsValue, A ;
MOV R1, #Low(PortA_OUT)
MOV A, #0010H ; Set DIR and Reset = 0 and Data = 1
MOVX @R0, A
MOV A, #0FFH
MOVX @DPTR, A ; Setup Port A for OUTPUT
MOV R2, #0011 ; PortC, Code for Data and Clock = 1
MOV DisplayPosition, #-1 ; Allow for later INC
NextColumn:
CLR A ; First clear display to prevent ghosting
MOVX @R1, A ; Write to Port A
MOV A, R2 ; = 00x1, x = Data = 1 on Column 0, else 0
MOVX @R0, A ; Set clock HI to select next column
CLR A ; Set Data and Clock Low
MOVX @R0, A ; Complete strobe of hardware
INC DisplayPosition ; Point to next row of dots
MOV A, DisplayPosition
ADD A, #LEDBuffer ; Index into LED Buffer
MOV R0, A
MOV A, @R0 ; Get the next row of dots
MOVX @R1, A ; Update the display
Done: Ret